using System;
using System.Collections.Generic;
using System.Text;
using Common.Shared.Design;

namespace Common.Shared.Xml.Wddx {
	[WddxRoot("field")]
	public class WddxRecordsetField : WddxObject {
		private string _name;
		private List<WddxPrimitiveDataTypeObject> _items;

		public WddxRecordsetField ( ) {
			this.Items = new List<WddxPrimitiveDataTypeObject> ( );
		}

		public WddxRecordsetField ( string name ) : this(name,null) {

		}

		public WddxRecordsetField ( string name, List<WddxPrimitiveDataTypeObject> items ) : this() {
			this.Items.AddRange ( items );
		}

		[WddxElement]
		public List<WddxPrimitiveDataTypeObject> Items {
			get { return _items; }
			set { _items = value; }
		}
		
		[WddxAttribute("name")]
		public string Name {
			get { return _name; }
			set { _name = value; }
		}

		public WddxPrimitiveDataTypeObject this[ int index ] {
			get {
				return this.Items[ index ].Value as WddxPrimitiveDataTypeObject;
			}
		}

		public int Count {
			get { return this.Items.Count; }
		}


	}
}
